//    Copyright (C) Kherty.  All rights reserved.
namespace OpenLS.Spreadsheet
{
    public class UniqueValuesFormattingRule : StandardConditionalFormattingRule
    {
        internal override ConditionalFormattingType Type
        {
            get { return ConditionalFormattingType.UniqueValues; }
        }
        internal override bool Apply(Cell cell)
        {
            return ApplyStyle(cell, counter.IsUnique(cell.Value));
        }

        internal override void ApplyRange(Range range)
        {
            counter = new CellValueCounter(range);
        }
        internal override void PrepareBeforeWrite(ConditionalFormatting conditionalFormatting, FormatType formatType)
        {
            if (formatType == FormatType.Biff)
                this.Formula1 = string.Format("=SUM({0})", conditionalFormatting.Range.TopLeftCell.Label); ///\\\
        }


        private CellValueCounter counter;
    }
}
